package lc.q250_300;

import lc.q1_50.Q29;

public class Q290 {
    public String getHint(String secret, String guess) {
        int bulls = 0;
        int[] gnums = new int[10];
        int[] snums = new int[10];
        for (int i = 0; i < guess.length(); i++) {
            char si = secret.charAt(i);
            char gi = guess.charAt(i);
            if (si == gi) {
                bulls ++;
            } else {
                snums[si - '0'] ++;
                gnums[gi - '0'] ++;
            }
        }
        int mills = 0;
        for (int i = 0; i < 10; i++) {
            mills += Integer.min(gnums[i], snums[i]);
        }
        return bulls+"A"+mills+"B";
    }

    public static void main(String[] args) {
        Q290 q290 = new Q290();
        System.out.println(q290.getHint("1807", "7810"));
        System.out.println(q290.getHint("1123", "0111"));
    }
}
